﻿using System;
using System.Collections.Generic;

namespace System
{
    public sealed class Singleton<T>:BaseSingleton {
        private static T instance;
        public static T Instance {
            get => instance;
            set {
                instance = value;
                AllSingletons[typeof(T)] = value;
            }
        }
    }
    public class BaseSingleton {
        static BaseSingleton() {
            AllSingletons = new Dictionary<Type,object>();
        }
        public static IDictionary<Type,object> AllSingletons { get; }
    }
}